package main

import (
	"fmt"
	"reflect"
)

func main() {
	//定义并初始化了切片
	a := []int{1, 22, 3, 4, 5}
	c := [5]int{1, 22, 3, 4, 5}
	fmt.Println(a, "__", len(a))
	fmt.Println(a, "__", len(c))

	//a是切片 b有大小限制是数组 切片可以通过append扩容
	a = append(a, 66)
	//c = append(c, 1)
	fmt.Println(a, "__", len(a))

	//切片基于数组定义初始化
	b := c[0:0:0]
	fmt.Println(reflect.TypeOf(b), "....", b)
	b = append(b, 66, 66, 7, 8, 9)
	for k, v := range b {
		fmt.Println(k, v)
	}
	fmt.Println("len:", len(b), "cap:", cap(b))

	//make创建切片
	d := make([]int, 5, 5)
	d[1] = 6
	d = append(d, 9, 9)
	fmt.Println(d)
	fmt.Println("len:", len(d), "cap:", cap(d))

}
